package com.healthshare.parse.share;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.palmedia.framework.parse.BaseParse;




/**
 * @author xudeliang
 * 评论列表、我的评论、别人对我的内容评论。
 */
public class CommentParse extends BaseParse
{

	/*{
{
“commentlist”:[
{“nickname”:”用户昵称”,”comment”:”评论内容”,"timetype":"0","timevalue":"5" ,"content":"原内容" }，


	*/
	
	public ArrayList<CommentItem> commentItems = new ArrayList<CommentItem>();
	
	public CommentParse()
	{
		
	}
	
	@Override
	public boolean Parse(byte[]data)
	{
		boolean ret = super.Parse(data);
		if(!ret)
		{
			return false;
		}
		if(JSON==parseType)
		{
			try 
			{
				JSONArray ja = jsonObject.getJSONArray("commentlist");
				int len = ja.length();
				for(int i=0;i<len;i++)
				{
					CommentItem kv = new CommentItem();
					JSONObject iobject =ja.getJSONObject(i);
					kv.nickname = iobject.getString("nickname");
					kv.comment = iobject.getString("comment");
					kv.timetype = iobject.getString("timetype");
					kv.timevalue = iobject.getString("timevalue");
					kv.content = iobject.getString("content");
					commentItems.add(kv);
				}
				return true;
			} 
			catch (JSONException e) 
			{
				e.printStackTrace();
			}
		}
		return false;
	}
	
	public class CommentItem
	{
		public String nickname;
		public String comment;
		public String timetype;
		public String timevalue;
		public String content;
	}
}
